<?php

/**
 * Guzzle HTTP 客户端
 */
namespace App\Service\HttpServer;

use Hyperf\Contract\OnRequestInterface;

class HttpServer implements OnRequestInterface
{
    public function onTask($server, int $fd, int $fromId, string $data): void
    {
        echo json_encode([
                'fd' => $fd,
                'fromId' => $fromId,
                'data' => $data,
                'time'  => date('Y-m-d H:i:s')
            ], JSON_UNESCAPED_UNICODE).PHP_EOL;
        $server->send($fd, 'recv:' . $data);
    }
}